<script>
import config from './config'
import store from '@/store'
import {mapMutations,mapState} from 'vuex';

  export default {
	 globalData: {
	 	goLogin() {
	 		let _this = this
	 		uni.showModal({
	 			title: '提示',
	 			content: '请登录',
	 			success: res => {
	 				if (res.confirm) {
	 					console.log("去登陆!");
	 						uni.reLaunch({
	 							url:"/pages/public/login"
	 						})
	 				}
	 			}
	 		});
	 	},
	 	...config
	 }, 
    onLaunch() {
       this.initData()
    },
	computed: {
		...mapState(['hasLogin', 'userInfo', 'userCenterData'])
	},
    methods: {
	   ...mapMutations(['login', 'logout', 'setUserCenterData']),
       initData(){
		   
		   	let userInfo = uni.getStorageSync('userInfo') || '';
			let _this = this
			if (userInfo.access_token) {
				//更新登陆状态
				uni.getStorage({
					key: 'userInfo',
					success: (res) => {
						_this.login(res.data);
						_this.setUserCenterData(uni.getStorageSync('userCenterData'))
					}
				});
			}
			
		   uni.getSystemInfo({
		   	success: res => {
		   		// this.globalData.bottomSateArea = 0; //手机底部安全区域高度
		   		// let iphoneXArr = ["iPhone X", "iPhone 11", "iPhone 11 Pro Max", "iPhone XR",
		   		// 	"iPhoneXS"
		   		// ]; //iphone手机底部一条黑线
		   		// if (iphoneXArr.indexOf(res.model) != -1) {
		   		// 	this.globalData.bottomSateArea = "30rpx";
		   		// }
		   		// console.log(res);
		   		this.globalData.statusBarHeight = res.statusBarHeight;
		   		this.globalData.windowHeight = res.windowHeight;
		   		this.globalData.windowWidth = res.windowWidth;
		   		this.globalData.screenHeight = res.screenHeight;
		   		this.globalData.screenWidth = res.screenWidth;
		   	}
		   });
	   },
    }
  }
</script>

<style lang="scss">
  @import '@/static/scss/index.scss';
  
  .placeholder-class{
	  font-size: 24rpx;
	  color: #9FABAB;
	  padding-left: 15rpx;
  }
  /*边框*/
  .b_b:after,
  .b_t:after {
  	position: absolute;
  	z-index: 3;
  	left: 0;
  	right: 0;
  	height: 0;
  	content: '';
  	transform: scaleY(.5);
  	border-bottom: 1rpx solid rgba(0, 0, 0, .1);
  }
  
  .b_b:after {
  	bottom: 0;
  }
  
  .b_t:after {
  	top: 0;
  }
  
  .b-b:after {
  	bottom: 0;
  }
  
  .b-t:after {
  	top: 0;
  }
 
 
</style>
